<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">  <!-- 关键声明 -->
    <title>CORS 测试</title>
</head>
<body>
<button onclick="sendRequest()">发送跨域请求</button>
<script>
    function sendRequest() {
        fetch('http://localhost:8080/crossOrigin/hello') // 替换为你的后端API地址
            .then(response => {
                if (!response.ok) {
                    throw new Error('请求失败');
                }
                return response.json();
            })
            .then(data => {
                console.log('成功接收数据:', data);
            })
            .catch(error => {
                console.error('请求错误:', error);
            });
    }
</script>
</body>
</html>